import request from '@/utils/request'

// 查询已通过立项审核的项目列表
export function listApproved(query) {
  return request({
    url: '/project/planning/approved',
    method: 'get',
    params: query
  })
}

// 获取项目详情
export function getProjectInfo(projectId) {
  return request({
    url: `/project/planning/project/${projectId}`,
    method: 'get'
  })
}

// 获取工艺模板
export function getProcessTemplate(productIds) {
  return request({
    url: `/project/planning/processTemplate/${productIds}`,
    method: 'get'
  })
}

// 查询项目策划列表
export function listProjectPlanning(query) {
  return request({
    url: '/project/planning/list',
    method: 'get',
    params: query
  })
}

// 获取项目策划详情
export function getProjectPlanning(planningId, useType) {
  return request({
    url: `/project/planning/${planningId}`,
    method: 'get',
    params: { useType }
  })
}

// 新增项目策划
export function addProjectPlanning(data) {
  return request({
    url: '/project/planning',
    method: 'post',
    data: data
  })
}

// 修改项目策划
export function updateProjectPlanning(data) {
  return request({
    url: '/project/planning',
    method: 'put',
    data: data
  })
}

// 获取项目策划详情
export function getInfo(planningId, useType) {
  return request({
    url: `/project/planning/${planningId}`,
    method: 'get',
    params: { useType }
  })
}

// 获取工艺阶段的交付物列表
export function getDeliverables(stageId, templateId) {
  return request({
    url: `/project/planning/deliverables/${stageId}`,
    method: 'get',
    params: {
      templateId: templateId
    }
  })
}

// 删除项目策划
export function deleteProjectPlanning(planningId) {
  return request({
    url: `/project/planning/${planningId}`,
    method: 'delete'
  })
}

// 提交项目策划审核
export function submitForApproval(data) {
  return request({
    url: '/project/planning/submit',
    method: 'post',
    data: data
  })
}